package model

import (
	"errors"
	"github.com/dailing/levlog"
	"time"
)

type Record struct {
	Id                   int64     `json:"id"`
	SongId               int64     `json:"song_id"`
	UserId               int64     `json:"user_id"`
	IsOriginalSinger     bool      `json:"is_original_singer"`
	IsProfessionalSinger bool      `json:"is_professional_singer"`
	Created              time.Time `json:"created"`
	RecordId             int64     `json:"record_id"`
}

func (r *Record) Delete() error {
	panic("implement me")
}

func (r *Record) Get() error {
	ok, err := engine.Get(r)
	if !ok {
		return errors.New("no such record")
	}
	return err
}

func (r *Record) Update() error {
	_, err := engine.Update(r)
	return err
}

func (r *Record) Insert() error {
	_, err := engine.Insert(r)
	levlog.E(err)
	return err
}

func (r *Record) SetBinRec([]byte) error {
	_, err := engine.Id(r.Id).Cols("bin_record").Update(r)
	levlog.E(err)
	return err
}
